package cn.sh.yhk.consume;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.context.annotation.ImportResource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.sh.yhk.admin.model.AdminUser;
import cn.sh.yhk.api.UserService;

/**
 * Hello world!
 *
 */
@ImportResource("classpath:consume.xml")
@Controller
@SpringBootApplication
public class App implements EmbeddedServletContainerCustomizer {

	@Autowired
	private UserService userService;

	@RequestMapping("/home")
	@ResponseBody
	public AdminUser home() throws Exception {
		return userService.getUserName(new AdminUser());
	}

	public static void main(String[] args) throws Exception {
		SpringApplication.run(App.class, args);
	}

	@Override
	public void customize(ConfigurableEmbeddedServletContainer arg0) {
		arg0.setPort(8083);
	}
}
